<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    /*     要求用户输入行数和列数生成表格，例如用户输入2行3列，生成的表格代码如下：
    <table>
        <tr>
            <td>1行1列</td>
            <td>1行2列</td>
            <td>1行3列</td>
        </tr>
        <tr>
            <td>2行1列</td>
            <td>2行2列</td>
            <td>2行3列</td>
        </tr>
    </table> */

    // 声明链接字符串
    let str = '';

    // 循环行
    str += '<table>\n'
    for (let i = 1; i <= 2; i++) {
        str += '<tr>\n'
        // 循环列
        for (let j = 1; j <= 3; j++) {
            str += `<td>${i}行${j}列</td>\n`
        }
        str += '</tr>\n'
    }
    str += '</table>'

    // 打印
    console.log(str);
</script>

</html>